        <!DOCTYPE html>
        <html>
        <head>
                <meta charset="utf-8">
        <title>StringDescription class / matcher Library / Dart Documentation</title>
        <link rel="stylesheet" type="text/css"
            href="../styles.css">
        <link href="http://fonts.googleapis.com/css?family=Open+Sans:400,600,700,800" rel="stylesheet" type="text/css">
        <link rel="shortcut icon" href="../favicon.ico">
        
        </head>
        <body data-library="matcher" data-type="StringDescription">
        <div class="page">
        <div class="header">
          <a href="../index.html"><div class="logo"></div></a>
          <a href="../index.html">Dart Documentation</a>
         &rsaquo; <a href="../matcher.html">matcher</a> &rsaquo; <a href="../matcher/StringDescription.html">StringDescription</a>        <div id="search-box">
          <input type="search" name="q" id="q" autocomplete="off"
              class="search-input" placeholder="Search API">
        </div>
        
      </div>
      <div class="drop-down" id="drop-down"></div>
      
        <div class="nav">
        
</div>
<div class="content">
        <h2><strong>StringDescription</strong>
          class
        </h2>
        
<button id="show-inherited" class="show-inherited">Hide inherited</button>
<div class="doc">
<p>The default implementation of IDescription. This should rarely need
substitution, although conceivably it is a place where other languages
could be supported.</p>
<pre class="source">
class StringDescription implements Description {
 var _out;

 /** Initialize the description with initial contents [init]. */
 StringDescription([String init = '']) {
   _out = init;
 }

 /** Get the description as a string. */
 String toString() =&gt; _out;

 /** Append some plain [text] to the description.  */
 Description add(String text) {
   _out = '${_out}${text}';
   return this;
 }

 /** Change the value of the description. */
 Description replace(String text) {
   _out = text;
   return this;
 }

 /**
  * Appends a description of [value]. If it is an IMatcher use its
  * describe method; if it is a string use its literal value after
  * escaping any embedded control characters; otherwise use its
  * toString() value and wrap it in angular "quotes".
  */
 Description addDescriptionOf(value) {
   if (value is Matcher) {
     value.describe(this);
   } else if (value is String) {
     _addEscapedString(value);
   } else {
     String description = (value == null) ? "null" : value.toString();
     if (description.startsWith('&lt;') &amp;&amp; description.endsWith('&gt;')) {
         add(description);
     } else if (description.startsWith("Instance of")) {
       add('&lt;');
       add(description);
       add(':');
       add(value.hashCode.toString());
       add('&gt;');
     } else {
       add('&lt;');
       add(description);
       add('&gt;');
     }
   }
   return this;
 }

 /**
  * Append an [Iterable] [list] of objects to the description, using the
  * specified [separator] and framing the list with [start]
  * and [end].
  */
 Description addAll(String start, String separator, String end,
                      Iterable list) {
   var separate = false;
   add(start);
   for (var item in list) {
     if (separate) {
       add(separator);
     }
     addDescriptionOf(item);
     separate = true;
   }
   add(end);
   return this;
 }

 /** Escape the control characters in [string] so that they are visible. */
 _addEscapedString(String string) {
   add("'");
   for (var i = 0; i &lt; string.length; i++) {
     add(_escape(string[i]));
   }
   add("'");
 }

 /** Return the escaped form of a character [ch]. */
 _escape(ch) {
   if (ch == "'")
     return "\'";
   else if (ch == '\n')
     return '\\n';
   else if (ch == '\r')
     return '\\r';
   else if (ch == '\t')
     return '\\t';
   else
     return ch;
 }
}
</pre>
</div>
<h3>Implements</h3>
<p>
<span class="type-box"><span class="icon-class"></span><a href="../matcher/Description.html">Description</a></span></p>
<div>
<h3>Constructors</h3>
<div class="method"><h4 id="StringDescription">
<button class="show-code">Code</button>
new <strong>StringDescription</strong>([String init = '']) <a class="anchor-link" href="#StringDescription"
              title="Permalink to StringDescription.StringDescription">#</a></h4>
<div class="doc">
<p>Initialize the description with initial contents 
<span class="param">init</span>. </p>
<pre class="source">
StringDescription([String init = '']) {
 _out = init;
}
</pre>
</div>
</div>
</div>
<div>
<h3>Methods</h3>
<div class="method"><h4 id="add">
<button class="show-code">Code</button>
<a href="../matcher/Description.html">Description</a> <strong>add</strong>(String text) <a class="anchor-link" href="#add"
              title="Permalink to StringDescription.add">#</a></h4>
<div class="doc">
<p>Append some plain 
<span class="param">text</span> to the description.  </p>
<pre class="source">
Description add(String text) {
 _out = '${_out}${text}';
 return this;
}
</pre>
</div>
</div>
<div class="method"><h4 id="addAll">
<button class="show-code">Code</button>
<a href="../matcher/Description.html">Description</a> <strong>addAll</strong>(String start, String separator, String end, Iterable list) <a class="anchor-link" href="#addAll"
              title="Permalink to StringDescription.addAll">#</a></h4>
<div class="doc">
<p>Append an [Iterable] [list] of objects to the description, using the
specified 
<span class="param">separator</span> and framing the list with 
<span class="param">start</span>
and 
<span class="param">end</span>.</p>
<pre class="source">
Description addAll(String start, String separator, String end,
                    Iterable list) {
 var separate = false;
 add(start);
 for (var item in list) {
   if (separate) {
     add(separator);
   }
   addDescriptionOf(item);
   separate = true;
 }
 add(end);
 return this;
}
</pre>
</div>
</div>
<div class="method"><h4 id="addDescriptionOf">
<button class="show-code">Code</button>
<a href="../matcher/Description.html">Description</a> <strong>addDescriptionOf</strong>(value) <a class="anchor-link" href="#addDescriptionOf"
              title="Permalink to StringDescription.addDescriptionOf">#</a></h4>
<div class="doc">
<p>Appends a description of 
<span class="param">value</span>. If it is an IMatcher use its
describe method; if it is a string use its literal value after
escaping any embedded control characters; otherwise use its
toString() value and wrap it in angular "quotes".</p>
<pre class="source">
Description addDescriptionOf(value) {
 if (value is Matcher) {
   value.describe(this);
 } else if (value is String) {
   _addEscapedString(value);
 } else {
   String description = (value == null) ? "null" : value.toString();
   if (description.startsWith('&lt;') &amp;&amp; description.endsWith('&gt;')) {
       add(description);
   } else if (description.startsWith("Instance of")) {
     add('&lt;');
     add(description);
     add(':');
     add(value.hashCode.toString());
     add('&gt;');
   } else {
     add('&lt;');
     add(description);
     add('&gt;');
   }
 }
 return this;
}
</pre>
</div>
</div>
<div class="method"><h4 id="replace">
<button class="show-code">Code</button>
<a href="../matcher/Description.html">Description</a> <strong>replace</strong>(String text) <a class="anchor-link" href="#replace"
              title="Permalink to StringDescription.replace">#</a></h4>
<div class="doc">
<p>Change the value of the description. </p>
<pre class="source">
Description replace(String text) {
 _out = text;
 return this;
}
</pre>
</div>
</div>
<div class="method"><h4 id="toString">
<button class="show-code">Code</button>
String <strong>toString</strong>() <a class="anchor-link" href="#toString"
              title="Permalink to StringDescription.toString">#</a></h4>
<div class="doc">
<p>Get the description as a string. </p>
<pre class="source">
String toString() =&gt; _out;
</pre>
</div>
</div>
</div>
        </div>
        <div class="clear"></div>
        </div>
        <div class="footer">
          
        </div>
        <script async src="../client-live-nav.js"></script>
        </body></html>
        
